﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using Telerik.Windows.Documents.Fixed.Model.Editing;

namespace Com.Lancetinc.Evs.Reports.RadPdf;

public static class ExportHelper
{
    private static readonly PdfRenderer PdfRenderer;

    static ExportHelper()
    {
        PdfRenderer = new PdfRenderer();
        SetUp(PdfRenderer);
    }

    public static void ExportToPdf(FrameworkElement element, FixedContentEditor drawingSurface)
    {
        PdfRenderer.Render(element, drawingSurface);
    }

    private static void SetUp(PdfRenderer renderer)
    {
        renderer.AddRenderer(new PanelRenderer());
        renderer.AddRenderer(new TextBoxRenderer());
        renderer.AddRenderer(new TextBlockRenderer());
        renderer.AddRenderer(new BorderRenderer());
        renderer.AddRenderer(new RectangleRenderer());
        renderer.AddRenderer(new EllipseRenderer());
        renderer.AddRenderer(new LineRenderer());
        renderer.AddRenderer(new ImageRenderer());
        renderer.AddRenderer(new ShapeRenderer());
        renderer.AddRenderer(new FrameworkElementRenderer(
            typeof(ContentPresenter),
            typeof(Control),
            typeof(ItemsPresenter),
            typeof(AdornerLayer)));
    }
}